//
//  SpeedloanViewController.m
//  jiukeji
//
//  Created by 小宇 on 2017/11/24.
//  Copyright © 2017年 小宇. All rights reserved.
//

#import "SpeedloanViewController.h"
#import "JKJSpeedloanModel.h"
#import "YYModel.h"
@interface SpeedloanViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) NSArray<JKJSpeedloanModel*> *modelArray;
@end

@implementation SpeedloanViewController

- (void)viewDidLoad {
    [super viewDidLoad];
	[self loadData];
	self.view.backgroundColor = [UIColor whiteColor];
	self.navigationItem.title = @"极速贷款";

	UITableView *tabView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
	[self.view addSubview:tabView];
	//_tableView = tabView;
	tabView.rowHeight = 80;
	tabView.delegate = self;
	tabView.dataSource = self;
	[tabView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cellid"];
	tabView.bounces = NO;
	
	[tabView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.top.bottom.equalTo(self.view);
		make.right.left.equalTo(self.view);
		make.top.equalTo(self.view).offset(10);
	}];

	[tabView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
}

-(void)loadData{
	NSURL *url = [[NSBundle mainBundle]URLForResource:@"Speedloan.plist" withExtension:nil];

	NSArray *array = [NSArray arrayWithContentsOfURL:url];

	NSArray *modelArray = [NSArray yy_modelArrayWithClass:[JKJSpeedloanModel class] json:array];

	_modelArray = modelArray;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
	//return _modelArray.count;
	return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellid"];

	cell  = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cellid"];
	cell.imageView.image = [UIImage imageNamed:_modelArray[indexPath.row].icon];
	cell.textLabel.text = _modelArray[indexPath.row].name;
	cell.textLabel.textColor = [UIColor hm_colorWithHex:0x333333];
	cell.textLabel.font = [UIFont systemFontOfSize:14];
	cell.detailTextLabel.textColor = [UIColor hm_colorWithHex:0xa5a5a5];
	cell.detailTextLabel.font = [UIFont systemFontOfSize:11];
	cell.detailTextLabel.text = _modelArray[indexPath.row].destail;
	cell.selectionStyle = UITableViewCellSelectionStyleNone;
	//cell指示器
	cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

	//改变cell的点击颜色
	cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
	//cell.selectedBackgroundView.backgroundColor = [UIColor hm_colorWithHex:SELECT_CELL_COLOR];

	return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
